package com.kingbook.common.enums;

/**
 * @Author: Bucky
 * @Date: 2019/1/2 13:36
 * @Version 1.0
 */
public enum JavaType {

    UNKNOW("", ""),
    STRING("java.lang.String", "String"),
    INTEGER("java.lang.Integer", "int"),
    LONG("java.lang.Long", "long"),
    FLOAT("java.lang.Float", "float"),
    DOUBLE("java.lang.Double", "double"),
    BOOLEAN("java.lang.Boolean", "boolean"),
    BIGDECIMAL("java.math.BigDecimal", "BigDecimal"),
    DATE("java.sql.Date", "Date"),
    TIME("java.sql.Time", "Time"),
    TIMESTAMP("java.sql.Timestamp", "Timestamp"),
    BYTE_ARRAY("java.lang.byte[]", "byte[]");


    String fullName;

    String shortName;

    JavaType(String fullName, String shortName) {
        this.fullName = fullName;
        this.shortName = shortName;
    }


    public static JavaType getInstance(String shortName) {
        for(JavaType type :JavaType.values()){
            if(shortName.equalsIgnoreCase(type.getShortName()))
                return type;
        }
        return UNKNOW;
    }

    public String getFullName() {
        return fullName;
    }

    public String getShortName() {
        return shortName;
    }

    public boolean equals(String type) {
        return fullName.equals(type);
    }

}
